<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="custom" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <title>推送分组</title>
</head>

<body>
<div class="pageheader">
    <h2>推送分组</h2>
</div>
<div class="contentpanel">
    <form class="form-inline">
        <div class="btn-group mr10">
            <input type="text" class="form-control" name="name" value="${listDto.name}"
                   placeholder="请输入要查询的分组名">

            <select class="form-control categoryList" name="reportRuleUuid">
                <option value="">报表规则查询</option>
                <c:forEach items="${listDto.allReportRuleDto}" var="i">
                    <option value="${i.uuid}" ${listDto.reportRuleUuid eq i.uuid?"selected":""}>${i.name}</option>
                </c:forEach>
            </select>

            <button type="submit" class="form-control btn-success">查询</button>
        </div>
        <div class="btn-group mr10">
            <a class="btn btn-success"
               href="${contextPath}/admin/report/push_group/edit.htm">新增分组</a>
        </div>
    </form>
    <table class="table table-striped dataTable no-footer" id="table2" role="grid" aria-describedby="table2_info">
        <thead>
        <tr role="row">
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">分组名
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">推送表达式
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">报表规则
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">创建时间
            </th>
            <th class="sorting_asc" tabindex="0" aria-controls="table2"
                rowspan="1" colspan="1" aria-sort="ascending">状态
            </th>
            <th class="sorting" tabindex="0" aria-controls="table2" rowspan="1" colspan="1">操作
            </th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${listDto.list}" var="item" varStatus="status">
            <tr class="gradeA ${status.index/2 eq 0?"odd":"even"}">
                <custom:push_group_list_item item="${item}"/>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <custom:page page="${listDto}"/>
    <script type="text/javascript">
        <c:if test="${not empty param.edit}">
        jQuery.gritter.add({
            title: '添加/编辑成功!',
            class_name: "growl-success",
            sticky: false
        });
        </c:if>
        <c:if test="${not empty param.delete}">
        jQuery.gritter.add({
            title: '删除成功!',
            class_name: "growl-primary",
            sticky: false
        });
        </c:if>
    </script>
</div>

<script src="${contextPath}/resources/js/jquery.datatables.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('#table2').dataTable({
            "bPaginate": false,// 分页按钮
            "bFilter": false,// 搜索栏
            "bLengthChange": false,// 每行显示记录数
            "bInfo": false
        });
    });
    $(".table").on("click", ".ChangeState", function () {
        var uuid = $(this).attr('uuid');
        var name = $(this).attr('name');
        var state = $(this).attr('state');
        var tr = $(this).parents("tr");
        //禁用tr
        $(this).addClass("disabled");
        if (confirm('确定变更[' + name + ']的状态?')) {
            $.ajax({
                        url: 'change_state',
                        type: "post",
                        data: {uuid: uuid, state: state},
                        success: function (data) {
                            tr.html(data);
                        }
                    }
            );
        }
        $(this).removeClass("disabled");
    });
</script>
</body>
</html>